<%@ include file="CheckLogin.jsp"%>
<%@ include file="Connection.jsp"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.PreparedStatement"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel='stylesheet' type='text/css' href='css/thread.css' />
<link rel='stylesheet' type='text/css' href='css/index.css' />
<link rel='stylesheet' type='text/css' href='css/style.css' />
<link rel='stylesheet' type='text/css' href='css/menu.css' />
<link rel='stylesheet' type='text/css' href='css/footer.css' />
<title>HiRoom! - ${box.title}</title>

<style type='text/css'>
.pagination {
	text-align: center;
	margin: 7px 0 7px 0;
}

.pagination a {
	text-decoration: none;
}

.pagination span,.pagination a:hover {
	background: none repeat scroll 0% 0% #126183;
}

.pagination a,.cpage {
	padding: 5px 10px;
	margin: 2px;
	border-radius: 3px;
	background: none repeat scroll 0% 0% #29AAE2;
	border: 1px solid;
	color: #F5F5F5;
}
</style>

</head>
<body>
	<%@ include file="Header.jsp"%>

	<div id='wrapper'>
		<div class='separator'>
			<h2>Chuyên mục: ${box.title}</h2>
			<button type='button'
				onclick="window.location='thread?do=post&bid=${box.id}'">Bài
				viết mới</button>
		</div>

		<c:choose>
			<c:when test="${box.numOfThread>0}">
				<c:forEach var="thread" items="${box.threads}" varStatus="status">
					<div
						class="<c:choose><c:when test="${thread.state==1||thread.state==2}">new_thread</c:when><c:otherwise>normal_thread</c:otherwise></c:choose>">
						<h4>
							<c:if
								test="${thread.state==-1||thread.state==2||thread.state==4}">
								<img alt="Closed" src="images/lock.png">
							</c:if>
							<a href="thread?do=view&tid=${thread.id}">${thread.title}</a>
						</h4>
						<div>
							<span>bởi </span><a
								href='account?do=view&uid=${thread.account.id}'>${thread.account.username}</a>
							<span> trả lời: ${thread.reply} - xem: ${thread.see}</span>
							<c:choose>
								<c:when test="${account.type=='Admin'}">
									<a href='thread?do=del&tid=${thread.id}&bid=${thread.boxID}'
										title='Xóa' class='nof'><img src='images/delete.png'
										alt='Delete' /> </a>
									<a
										href='thread?do=setting&action=hide&tid=${thread.id}&bid=${thread.boxID}'
										title='${thread.state==3||thread.state==4?"Bỏ ẩn":"Ẩn"}'
										class='nof'><img
										src='images/${thread.state==3||thread.state==4?"show":"hide"}.png'
										alt='${thread.state==3||thread.state==4?"Show":"Hide"}' /> </a>
									<a
										href='thread?do=setting&action=close&tid=${thread.id}&bid=${thread.boxID}'
										title='${thread.state==-1||thread.state==2||thread.state==4?"Mở chủ đề":"Đóng chủ đề"}'
										class='nof'><img
										src='images/${thread.state==-1||thread.state==2||thread.state==4?"open":"close"}.png'
										alt='${thread.state==-1||thread.state==2||thread.state==4?"Open":"Close"}' />
									</a>
									<a
										href='thread?do=setting&action=caution&tid=${thread.id}&bid=${thread.boxID}'
										title='${thread.state==1||thread.state==2?"Gỡ chú ý":"Chú ý"}'
										class='nof'><img
										src='images/${thread.state==1||thread.state==2?"caution_sub":"caution_add"}.png'
										alt='${thread.state==1||thread.state==2?"Not Caution":"Caution"}' />
									</a>
								</c:when>
								<c:when test="${account.type=='SMod'}">
									<a
										href='thread?do=setting&action=hide&tid=${thread.id}&bid=${thread.boxID}'
										title='${thread.state==3||thread.state==4?"Bỏ ẩn":"Ẩn"}'
										class='nof'><img
										src='images/${thread.state==3||thread.state==4?"show":"hide"}.png'
										alt='${thread.state==3||thread.state==4?"Show":"Hide"}' /> </a>
									<a
										href='thread?do=setting&action=close&tid=${thread.id}&bid=${thread.boxID}'
										title='${thread.state==-1||thread.state==2||thread.state==4?"Mở chủ đề":"Đóng chủ đề"}'
										class='nof'><img
										src='images/${thread.state==-1||thread.state==2||thread.state==4?"open":"close"}.png'
										alt='${thread.state==-1||thread.state==2||thread.state==4?"Open":"Close"}' />
									</a>
									<a
										href='thread?do=setting&action=caution&tid=${thread.id}&bid=${thread.boxID}'
										title='${thread.state==1||thread.state==2?"Gỡ chú ý":"Chú ý"}'
										class='nof'><img
										src='images/${thread.state==1||thread.state==2?"caution_sub":"caution_add"}.png'
										alt='${thread.state==1||thread.state==2?"Not Caution":"Caution"}' />
									</a>
								</c:when>
								<c:when test="${account.type=='Mod'}">
									<a
										href='thread?do=setting&action=hide&tid=${thread.id}&bid=${thread.boxID}'
										title='${thread.state==3||thread.state==4?"Bỏ ẩn":"Ẩn"}'
										class='nof'><img
										src='images/${thread.state==3||thread.state==4?"show":"hide"}.png'
										alt='${thread.state==3||thread.state==4?"Show":"Hide"}' /> </a>
									<a
										href='thread?do=setting&action=close&tid=${thread.id}&bid=${thread.boxID}'
										title='${thread.state==-1||thread.state==2||thread.state==4?"Mở chủ đề":"Đóng chủ đề"}'
										class='nof'><img
										src='images/${thread.state==-1||thread.state==2||thread.state==4?"open":"close"}.png'
										alt='${thread.state==-1||thread.state==2||thread.state==4?"Open":"Close"}' />
									</a>
								</c:when>
							</c:choose>
						</div>
					</div>
				</c:forEach>
			</c:when>
			<c:otherwise>Chuyên mục hiện chưa có bài viết</c:otherwise>
		</c:choose>

		<c:if test="${sumPage>1}">
			<div class="pagination">
				<a
					href="?do=list&bid=${param.bid}&sz=${size}&p=${cPage>1?cPage-1:1}">&lt;</a>
				<c:forEach var="i" begin="1" end="${sumPage}">
					<c:choose>
						<c:when test="${i==cPage}">
							<span class="cpage">${i}</span>
						</c:when>
						<c:otherwise>
							<a href="?do=list&bid=${param.bid}&sz=${size}&p=${i}">${i}</a>
						</c:otherwise>
					</c:choose>
				</c:forEach>
				<a
					href="?do=list&bid=${param.bid}&sz=${size}&p=${cPage<sumPage?cPage+1:sumPage}">&gt;</a>
			</div>
		</c:if>
	</div>

	<jsp:include page="Footer.jsp"></jsp:include>
</body>
</html>